<?php
/*
 * 验证码
 * @author andery <andery@foxmail.com>
 * @link http://www.minophp.com/
 * @version $Id: CArray.lib.php 2010-07-08 23:12:10Z andery $
 */
class CCaptcha 
{
    private $_sm;
    public function __construct()
    {
        include_once(NM_VENDORS . '/captcha/securimage.php');
        $this->_sm = new securimage();
    }
    
    /**
     * 默认显示方式
     */
    public function show()
    {
        $this->_sm->image_width = 140;
        $this->_sm->image_height = 25;
        $this->_sm->code_length = 4;
        $this->_sm->text_x_start  = 15;
        $this->_sm->perturbation = 0;
        $this->_sm->use_gd_font = false;
        $this->_sm->ttf_file = NM_VENDORS . '/captcha/fonts/AHGBold.ttf';
        $this->_sm->text_color = new Securimage_Color("#ffeaea");
        $this->_sm->use_multi_text = false;
        $this->_sm->num_lines = 0;
        $this->_sm->line_color = new Securimage_Color("#d9d9d9");
        $this->_sm->draw_lines_over_text = false;
        $this->_sm->image_type = SI_IMAGE_PNG;
        $this->_sm->show(NM_VENDORS . '/captcha/backgrounds/bg1.jpg');
    }
    
    /**
     * 检查验证码
     */
    public function check($code)
    {
        return $this->_sm->check($code);
    }
}